<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('配件管理列表')" />
    <th:block th:include="include :: layout-latest-css" />
    <th:block th:include="include :: ztree-css" />
    <style>
        /*.changeColor{
            background-color: #23c6c8  !important;
            color: white;
        }*/
        .table-hover > tbody > tr:hover > td,
        .table-hover > tbody > tr:hover > th {
            color: #11d14f;
            cursor: pointer;
        }

    </style>
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <input type="hidden" id="partsType" name="partsType">
                    <input type="hidden" id="parentId" name="parentId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>厂家名称：</label>
                                <input type="text" name="factoryName"/>
                            </li>
                            <!--<li>
                                <label>产品名称：</label>
                                <input type="text" name="partsName"/>
                            </li>-->
                            <li>
                                <label>规格名称：</label>
                                <input type="text" name="attributeName"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table class="table-hover" id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: layout-latest-js" />
    <th:block th:include="include :: ztree-js" />
    <script th:inline="javascript">
        var partsDistinguishDatas = [[${@dict.getType('parts_brand')}]];
        var prefix = ctx + "zsyh/partsattribute";

        $(function() {
            queryPartsList();
        });
        function queryPartsList() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                pageSize: 4,
                pageNumber: 1,
                modalName: "规格管理",
                columns: [{
                    field : 'Number',
                    title : '序号',
                    align: 'center',
                    width: 20,
                    formatter : function(value, row, index) {
                        var pageSize = $('#bootstrap-table').bootstrapTable('getOptions').pageSize;//通过表的#id 可以得到每页多少条
                        var pageNumber = $('#bootstrap-table').bootstrapTable('getOptions').pageNumber;//通过表的#id 可以得到当前第几页
                        return pageSize * (pageNumber - 1) + index + 1;//返回每条的序号： 每页条数 * （当前页 - 1 ）+ 序号
                    }
                },
                {
                    field: 'id',
                    title: '产品Id',
                    visible: false
                },
                /*{
                    field: 'factoryId',
                    title: '厂家信息Id'
                },*/
                    {
                        field: 'attributeLogo',
                        title: '规格主图',
                        formatter: function (value, row, index) {
                            return $.table.imageView(value);
                        }
                    },
                    {
                        field: 'attributeName',
                        title: '规格名称'
                    },
                    {
                        field: 'partsUnit',
                        align: 'center',
                        title: '产品单位'
                    },
                {
                    field: 'factoryName',
                        align: 'center',
                    title: '厂家名称'
                },
                {
                    field: 'attributePayPrice',
                    title: '补助金金额',
                    align: 'center'
                },
                {
                    field: 'attributeDistinguish',
                    title: '产品品牌',
                    align: 'center',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(partsDistinguishDatas, value);
                    }
                }],onDblClickRow: function (row) {
                    parent.$('#attributeId').val(row.id);
                    parent.$('#attributeName').val(row.attributeName);
                    parent.$('#partsId').val(row.partsId);
                    parent.$('#factoryId').val(row.factoryId);
                    parent.$('#factoryName').val(row.factoryName);
                    parent.$('#factoryId').val(row.factoryId);
                    parent.$('#payPrice').val(row.attributePayPrice);
                    $.modal.close();
                },
                onClickRow:function (row,$element) {
                    $('.changeColor').removeClass('changeColor');//移除class
                    $($element).addClass('changeColor');//添加class
                }
            };
            $.table.init(options);
        };


    </script>
</body>
</html>